package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.entity.Collect;
import com.cskaoyan.bean.vo.BasePageData;
import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.bean.vo.CollectInfoVo;
import com.cskaoyan.bean.vo.CommonRespVo;
import com.cskaoyan.controller.wx.service.WxCollectService;
import com.cskaoyan.controller.wx.service.WxCollectServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 商品收藏
 * @Auther Wenjian_Yang
 * @Date 2021/10/22
 */
@RestController
@RequestMapping("wx/collect")
public class WxCollectController {

    @Resource
    WxCollectService wxCollectService;

    //商品收藏列表信息
    @GetMapping("list")
    public BaseRespVo list(CollectInfoVo collectInfoVo){
        BasePageData query = wxCollectService.query(collectInfoVo);
        return BaseRespVo.ok(query);
    }

    //取消或增加商品到收藏栏
    @PostMapping("addordelete")
    public CommonRespVo addOrDelete(@RequestBody Map map){
        boolean addOrDelete = wxCollectService.addOrDelete(map);
        if (!addOrDelete) return CommonRespVo.fail("服务器正在维护中，请稍后！");
        return CommonRespVo.ok();
    }


}
